import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute} from "@angular/router";

@Component({
  selector: 'app-explain',
  templateUrl: './explain.component.html',
  styleUrls: ['./explain.component.css'],
})
export class ExplainComponent implements OnInit {
  trainingID: string;
  classID: string;

  constructor(private router: Router,
              private routerInfo: ActivatedRoute) {
  }

  ngOnInit() {
    this.trainingID = this.routerInfo.snapshot.params.ID;
    this.classID = this.routerInfo.snapshot.params.classID;
  }

//  去到答题界面
  goAnswer() {
    if (this.classID) {
      this.router.navigate(['../answer', {ID: this.trainingID}], {relativeTo: this.routerInfo});
    } else {
      //跳转到信息填写页面
      this.router.navigate(['../upload', {ID: this.trainingID}], {relativeTo: this.routerInfo});
    }
  }

}
